<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>支付页面</title>
    <script src="/jquery.js"></script>
</head>
<body>

<input id="commodityId" th:value="${commodityId}" type="hidden">
<div>
    <p>商品ID:<span th:text="${commodityId}"></span></p>
    <img height="200px" onclick="pay()" src="/image/pay.jpg">
</div>
<script type="text/javascript">
    function pay() {
        const commodityId = document.getElementById('commodityId').value;
        $.post('/pay/' + commodityId, function (res) {
            if (res.success) {
                alert("支付成功");
            } else {
                alert(res.message);
            }
            window.location = '/page/order/' + commodityId;
        })
    }
</script>
</body>
</html>